﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace PaintDotNetForms
{
    public class Eclipse : Figure
    {
        public override void draw(System.Drawing.Graphics g)
        {
            int width = Math.Abs(endPoint.X - startPoint.X);
            int height = Math.Abs(endPoint.Y - startPoint.Y);
            int x = startPoint.X, y = startPoint.Y;
            
            if (endPoint.X < startPoint.X)
                x = endPoint.X;

            if (endPoint.Y < startPoint.Y)
                y = endPoint.Y;

            switch (Filling)
            {
                case Filling.Outline:
                    g.DrawEllipse(pen, x, y, width, height);
                    break;
                case Filling.Filled:
                    g.FillEllipse(brush, x, y, width, height);
                    break;
                case Filling.FilledWithOutline:
                    g.DrawEllipse(pen, x, y, width, height);
                    g.FillEllipse(brush, x, y, width, height);
                    break;
            }

            if (SizeChangeEvent != null)
                SizeChangeEvent(new Size(width, height));
        }

        public override event SizeChange SizeChangeEvent;
    }
}
